#!/bin/sh
# Create a loadable object from a C++ function defined in a .cpp file
# $Id$

# Default compiler
if [ "$CXX" == "" ];
then
    CXX=g++
fi

FFsource=..
INC="-I$FFsource -I$FFsource/src/fflib -I$FFsource/src/femlib -I$FFsource/src/Graphics -I$FFsource/3rdparty/fftw/include" 
file=$1
shift
if [ -f "$file.cpp" ] ; then
    case `uname -s` in
	Darwin)
	export MACOSX_DEPLOYMENT_TARGET=10.3
	SHARED="-bundle -undefined dynamic_lookup"  ;;
	Linux|FreeBSD|CYGWIN*)
	SHARED="-shared " ;;
	*)
	echo "sorry unknown achitecture "`uname`
	exit 1
    esac

    echo $CXX -c $INC $PIC $file.cpp
    $CXX -c $INC $PIC  $file.cpp

    echo $CXX $SHARED $file.o -o $file.so $*
    $CXX $SHARED $file.o -o $file.so $*

else
    echo "sorry file $file.cpp does not exist"
fi
